<?php
define('R_P',getdirname(__FILE__));
define('D_P',R_P);
!defined('SCR') && define('SCR','other');
require_once(D_P.'sql_config.php');

echo "in global_1<BR>";
require_once(R_P.'lot_RBBall.php');
echo "in global2<BR>";
$db = null;
$lotRBBall = null;
echo "new DB<BR>";
NewDB();
echo "new lotter<BR>";
$lotRBBall = new CLotterRBBall($db, "cms_lottery");
function NewDB(){
	if (!is_object($GLOBALS['db'])) {
		global $db,$database,$dbhost,$dbuser,$dbpw,$dbname,$pconnect,$lotRBBall;
		
		require_once(R_P."db_$database.php");
		//require_once Pcv(R_P."db_$database.php");
		$db = new DB($dbhost,$dbuser,$dbpw,$dbname,$pconnect);
	}
}
function getdirname($path=null){
	if (!empty($path)) {
		if (strpos($path,'\\')!==false) {
			return substr($path,0,strrpos($path,'\\')).'/';
		} elseif (strpos($path,'/')!==false) {
			return substr($path,0,strrpos($path,'/')).'/';
		}
	}
	return './';
}
function Pcv($filename,$ifcheck=1){
	$tmpname = strtolower($filename);
	if (strpos($tmpname,'http://')!==false || ($ifcheck && strpos($tmpname,'..')!==false)) {
		exit('Forbidden');
	}
	return $filename;
}
?>
